import request from '@/utils/requestDevote'
const moduleApi = '/operation'

/**
 * 投放计划组列表
 * @param {Object} data
 * @returns
 */
export function getDevoteList(data) {
  return request({
    url: moduleApi + '/placement_plan/search',
    method: 'post',
    data
  })
}

/**
 * 新增计划组
 * @param {Object} data
 * @returns
 */
export function addDevote(data) {
  return request({
    url: moduleApi + '/placement_plan',
    headers: { repeatSubmit: false },
    method: 'post',
    data
  })
}

/**
 * 修改计划组
 * @param {Object} data
 * @returns
 */
export function updateDevote(data) {
  return request({
    url: moduleApi + '/placement_plan',
    headers: { repeatSubmit: false },
    method: 'put',
    data
  })
}

/**
 * 删除计划组
 * @param {Object} data
 * @returns
 */
export function deleteDevote(data) {
  return request({
    url: moduleApi + `/placement_plan`,
    headers: { repeatSubmit: false },
    method: 'delete',
    data
  })
}

/**===========================================================餐品投放计划================================================ */

/**
 * 投放餐品计划列表
 * @param {Object} data
 * @returns
 */
export function getComboPlanList(params) {
  return request({
    url: moduleApi + '/placement_plan/combo_plan/search',
    method: 'get',
    params
  })
}

/**
 * 新增餐品投放计划
 * @param {Object} data
 * @returns
 */
export function addComboPlanDevote(data) {
  return request({
    url: moduleApi + '/placement_plan/combo_plan',
    headers: { repeatSubmit: false },
    method: 'post',
    data
  })
}

/**
 * 修改餐品投放计划
 * @param {Object} data
 * @returns
 */
export function updateComboPlanDevote(data) {
  return request({
    url: moduleApi + '/placement_plan/combo_plan',
    headers: { repeatSubmit: false },
    method: 'put',
    data
  })
}

/**
 * 修改餐品投放计划状态
 * @param {Object} data
 * @returns
 */
export function changeComboPlanStatus(data) {
  return request({
    url: moduleApi + `/placement_plan/combo_plan/status`,
    headers: { repeatSubmit: false, 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'put',
    data
  })
}

/**
 * 根据餐品计划id获取设备信息
 * @param {String} c_plan_id
 * @returns
 */
export function getComboMachineInfo(c_plan_id) {
  return request({
    url: moduleApi + `/placement_plan/combo_plan/device/by_c_plan_id?c_plan_id=${c_plan_id}`,
    method: 'get'
  })
}

/**
 * 根据餐品计划id获取货道餐品信息
 * @param {String} c_plan_id
 * @returns
 */
export function getComboRoadInfo(c_plan_id) {
  return request({
    url: moduleApi + `/placement_plan/combo_plan/road/by_c_plan_id?c_plan_id=${c_plan_id}`,
    method: 'get'
  })
}

/**
 * 投放餐品计划选择商品下架
 * @param {Object} data
 * @returns
 */
export function offShelfComboRoad(data) {
  return request({
    url: moduleApi + `/placement_plan/combo_plan/road/combo/ban`,
    headers: { repeatSubmit: false },
    method: 'put',
    data
  })
}
